BaseOrderedChannel

Ecng.Collections

Represents a base class for an ordered blocking queue that sorts values based on a specified key.

Constructors

BaseOrderedChannel
protected BaseOrderedChannel(TCollection collection, int maxSize)
baseOrderedChannel = BaseOrderedChannel(collection, maxSize)

Initializes a new instance with a specified maximum size.

collection
Inner collection.
maxSize
Maximum queue size. Use -1 for unbounded.

Properties

Count
public int Count { get; }
value = baseOrderedChannel.Count

Gets the number of cached assemblies.

IsClosed
public bool IsClosed { get; }
value = baseOrderedChannel.IsClosed

Gets a value indicating whether the queue is closed.

MaxSize
public int MaxSize { get; }
value = baseOrderedChannel.MaxSize

Gets the maximum number of values that the queue can hold.

Methods

Clear
public void Clear()
baseOrderedChannel.Clear()

Clears all cached assemblies.

Close
public void Close()
baseOrderedChannel.Close()

Closes the queue to prevent further enqueuing operations.

DequeueAsync
public ValueTask<TValue> DequeueAsync(CancellationToken cancellationToken)
result = baseOrderedChannel.DequeueAsync(cancellationToken)

Removes and returns the next value from the queue, waiting if necessary until a value becomes available.

cancellationToken
CancellationToken

Returns: The next value from the queue.

Enqueue
protected ValueTask Enqueue(TSort sort, TValue value, CancellationToken cancellationToken)
result = baseOrderedChannel.Enqueue(sort, value, cancellationToken)

Adds the specified item with associated sort to the queue.

sort
The sort with which to associate the new value.
value
The value to add to the queue.
cancellationToken
CancellationToken
Open
public void Open()
baseOrderedChannel.Open()

Opens the queue, enabling enqueuing and dequeuing operations.

ReadAllAsync
public IAsyncEnumerable<TValue> ReadAllAsync(CancellationToken cancellationToken)
result = baseOrderedChannel.ReadAllAsync(cancellationToken)

Returns an async enumerable that yields messages from the queue.

cancellationToken
Cancellation token.

Returns: Async enumerable of messages.